Ext.define('PJ.view.studentfeedbackministries.FeedbackEdit', {
	extend: 'AM.default.DefaultWindowForm',
	alias: ['widget.studentFeedbackEdit'],
	requires: ['AM.default.DefaultDateField', 
	           'AM.default.DateTime',
	           'AM.default.jsonp.DefaultSubmitJsonp',
	           'AM.default.DefaultDateField'],

	modal: true,// 开启不允许点击其他组件
	frame: true,
	notEdit: true,
	width: 400,
	height:150,
	layout: 'form',
	isSame: false,
	initComponent: function(){
    	var me = this;
    	var bt = me.isReadOnly?'':'<span style="color:red;">*</span>';
    	me.items= [{
    		defaults: {
    			labelAlign: 'right',
    			labelWidth: 90,
    			columnWidth: .5,
    			padding:"9 0 0 0"
    		},
    		border: false,
    		xtype: "container",
    		width: 380,
    		height:150,
    		layout: 'column',
    		allowBlank: false,
    		items: [{
    			xtype:"textarea",
    			fieldLabel:bt+"评价内容",
    			name:"appraise",
    			height:50,
    			width:400,
    			labelWidth: 65,
    			columnWidth: .98,
    			maxLength : 200,
    			readOnly: me.isReadOnly,
    			allowBlank: me.isReadOnly? true:false,
    			maxLengthText : "最多输入200个字"
    		}]
    	}];
		this.buttons = [{
            text: '确定',
            hidden: me.isReadOnly,
            handler: function(button, event){
                var win = button.up('window');
                win.sub();
            }
        }, {
            text: '取消',
            scope: this,
            hidden: me.isReadOnly,
            handler: this.close
        }, {
            text: '关闭',
            scope: this,
            hidden: !me.isReadOnly,
            handler: this.close
        }];
		this.callParent(arguments);
	},
    listeners: {
    	afterrender: function(){
            this.loadMask = new Ext.LoadMask(this, {
                msg: "正在加载中,请稍后...."
            });
        }
    },
    sub: function(){
    	var win = this;
    	var form = win.down('form');
    	var baseForm = form.getForm();
    	if (!baseForm.isValid()) {
    		return;
    	}
		var editUrl = win.commentUrl;
		if(gj_onlineLearning_constant.loadType == "jsonp"){
			win.down('panel').getForm().doAction("submitJsonp",{
				url: editUrl,
				params: {
					searchClassUserIds:win.classUserIds
					//searchClassID: win.searchClassID
				},
				success: function(f, action){
					if (action.result.success) {
						Ext.Msg.alert('提示', '操作成功！', function(){
							win.grid.getStore().load();
							win.close();
						});
					}else{
						Ext.Msg.alert('提示', action.result.msg, function(){
							win.close();
						});
					}
				},
				failure: function(f, action){
					if (action.result) {
						Ext.Msg.alert('提示', action.result.msg, function(){
							win.close();
						});
					}
					else {
						Ext.Msg.alert('提示', '操作失败！', function(){
							win.close();
						});
					}
				}
			});
		}else{
        	win.submit({
    			url: editUrl,
    			params: {
    				searchClassUserIds:win.classUserIds
    				//searchClassID: win.searchClassID
				},
        		success: function(f, action){
        			if (action.result.success) {
        				Ext.Msg.alert('提示', '操作成功！', function(){
        					win.grid.getStore().load();
            				win.close();
        				});
        			}else{
        				Ext.Msg.alert('提示', action.result.msg, function(){
        					win.close();
        				});
        			}
        		},
        		failure: function(f, action){
        			if (action.result) {
        				Ext.Msg.alert('提示', action.result.msg, function(){
        					win.close();
        				});
        			}
        			else {
        				Ext.Msg.alert('提示', '操作失败！', function(){
        					win.close();
        				});
        			}
        		}
        	});
        }
    }
});